package com.design.softwaredesign.controller;

import com.design.softwaredesign.service.BackStatisticsService;
import com.design.softwaredesign.utils.model.LineChartsDataModel;
import com.design.softwaredesign.utils.model.PanelGroupDataModel;
import com.design.softwaredesign.vo.BarVo;
import com.design.softwaredesign.vo.StatisticsVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

/**
 * @author :WaiterXiaoYY
 * @description: TODO
 * @data :2020/11/3 17:50
 */
@Api(description = "管理员接口控制-统计分析")
@RestController
@RequestMapping("/web/admin")
public class BackStatisticsController {
    @Autowired
    private BackStatisticsService backStatisticsService;
    @GetMapping("/getlinechartsdata")
    public StatisticsVo getLineChartsData() {
        StatisticsVo statisticsVo = new StatisticsVo<LineChartsDataModel>();
        statisticsVo.setCode(200);
        statisticsVo.setMsg("获取数据成功");
        HashMap<String, LineChartsDataModel> lineChartsDataModelHashMap = new HashMap<>();

        LineChartsDataModel lineChartsDataModel1 = new LineChartsDataModel();
        Integer[] expectedData = {44, 192, 120, 144, 160, 130, 140};
        Integer[] actualData = {31, 160, 151, 106, 145, 150, 130};
        lineChartsDataModel1.setExpectedData(expectedData);
        lineChartsDataModel1.setActualData(actualData);
        lineChartsDataModel1.setExpected("新用户");
        lineChartsDataModel1.setActual("登录用户");

        lineChartsDataModelHashMap.put("user", lineChartsDataModel1);

        LineChartsDataModel lineChartsDataModel2 = new LineChartsDataModel();
        Integer[] expectedData1 = {134, 492, 120, 144, 160, 130, 140};
        Integer[] actualData1 = {223, 243, 151, 106, 145, 150, 130};
        lineChartsDataModel2.setExpectedData(expectedData1);
        lineChartsDataModel2.setActualData(actualData1);
        lineChartsDataModel2.setExpected("已交易");
        lineChartsDataModel2.setActual("未交易");

        lineChartsDataModelHashMap.put("traded", lineChartsDataModel2);

        LineChartsDataModel lineChartsDataModel3 = new LineChartsDataModel();
        Integer[] expectedData2 = {56, 182, 120, 144, 160, 130, 140};
        Integer[] actualData2 = {67, 79, 151, 106, 145, 150, 130};
        lineChartsDataModel3.setExpectedData(expectedData2);
        lineChartsDataModel3.setActualData(actualData2);
        lineChartsDataModel3.setExpected("已交易");
        lineChartsDataModel3.setActual("未交易");

        lineChartsDataModelHashMap.put("untraded", lineChartsDataModel3);

        LineChartsDataModel lineChartsDataModel4 = new LineChartsDataModel();
        Integer[] expectedData3 = {32, 114, 120, 144, 160, 130, 140};
        Integer[] actualData3 = {14, 345, 151, 106, 145, 150, 130};
        lineChartsDataModel4.setExpectedData(expectedData3);
        lineChartsDataModel4.setActualData(actualData3);
        lineChartsDataModel4.setExpected("已送达");
        lineChartsDataModel4.setActual("未接收");

        lineChartsDataModelHashMap.put("donation", lineChartsDataModel4);
        statisticsVo.setData(lineChartsDataModelHashMap);

        return statisticsVo;
    }

    @GetMapping("/getpanelgroupdata")
    public StatisticsVo getPanelGroupData() {
        StatisticsVo statisticsVo = new StatisticsVo<PanelGroupDataModel>();
        statisticsVo = backStatisticsService.getPanelGroupData();
//        HashMap<String, PanelGroupDataModel> panelGroupDataModelHashMap = new HashMap<>();
//        PanelGroupDataModel panelGroupDataModel = new PanelGroupDataModel();
//        panelGroupDataModel.setUser(200);
//        panelGroupDataModel.setPost(352);
//        panelGroupDataModel.setComment(5894);
//        panelGroupDataModel.setReport(52);
//        panelGroupDataModelHashMap.put("panelgroup", panelGroupDataModel);
//        statisticsVo.setData(panelGroupDataModelHashMap);
//        statisticsVo.setCode(200);
//        statisticsVo.setMsg("获取数据成功");
        return statisticsVo;
    }

//    @GetMapping("/getagechartdata")
//    public StatisticsVo getAgeChartData() {
//        StatisticsVo statisticsVo = new StatisticsVo<List>();
//        statisticsVo = webStatisticsService.getAgeChartData();
//        List<PieChartDataModel> pieChartDataModelList = new ArrayList<>();
//        HashMap<String, List> listHashMap = new HashMap<>();
//        PieChartDataModel pieChartDataModel1 = new PieChartDataModel("17岁以下", 200);
//        PieChartDataModel pieChartDataModel2 = new PieChartDataModel("18-24岁", 45);
//        PieChartDataModel pieChartDataModel3 = new PieChartDataModel("25-29岁",45);
//        PieChartDataModel pieChartDataModel4 = new PieChartDataModel("30-39岁",256);
//        PieChartDataModel pieChartDataModel5 = new PieChartDataModel("40-49岁",563);
//        PieChartDataModel pieChartDataModel6 = new PieChartDataModel( "50岁以上",368);
//        pieChartDataModelList.add(pieChartDataModel1);
//        pieChartDataModelList.add(pieChartDataModel2);
//        pieChartDataModelList.add(pieChartDataModel3);
//        pieChartDataModelList.add(pieChartDataModel4);
//        pieChartDataModelList.add(pieChartDataModel5);
//        pieChartDataModelList.add(pieChartDataModel6);
//        listHashMap.put("agechart", pieChartDataModelList);
//        statisticsVo.setData(listHashMap);
//        statisticsVo.setCode(200);
//        statisticsVo.setMsg("获取数据成功");
//        return statisticsVo;
//    }

    @GetMapping("/getsexchartdata")
    public StatisticsVo getSexChartData() {
        StatisticsVo statisticsVo = new StatisticsVo<List>();
        statisticsVo = backStatisticsService.getSexChartData();
//        List<PieChartDataModel> pieChartDataModelList = new ArrayList<>();
//        HashMap<String, List> listHashMap = new HashMap<>();
//        PieChartDataModel pieChartDataModel1 = new PieChartDataModel("男性", 200);
//        PieChartDataModel pieChartDataModel2 = new PieChartDataModel("女性", 45);
//        PieChartDataModel pieChartDataModel3 = new PieChartDataModel("保密",45);
//        pieChartDataModelList.add(pieChartDataModel1);
//        pieChartDataModelList.add(pieChartDataModel2);
//        pieChartDataModelList.add(pieChartDataModel3);
//
//        listHashMap.put("sexchart", pieChartDataModelList);
//        statisticsVo.setData(listHashMap);
//        statisticsVo.setCode(200);
//        statisticsVo.setMsg("获取数据成功");
        return statisticsVo;
    }

    @GetMapping("/getbarchartdata")
    public BarVo getBarChartData() {
        return backStatisticsService.getBarChartData();
//        HashMap<String, Integer[]> barHashMap = new HashMap<>();
//        Integer[] cryptonym = {79, 345, 200, 334};
//        barHashMap.put("cryptonym", cryptonym);
//
//        Integer[] publicly = {234, 547, 86, 45};
//        barHashMap.put("publicly", publicly);
//        statisticsVo.setData(barHashMap);
//        statisticsVo.setCode(200);
//        statisticsVo.setMsg("获取数据成功");
    }
}
